app.service('questionTypeService',['$q','utilService',function($q,utilService){

    this.add = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'question/type',
            data:{name:$scope.questionType.name},
            method:'POST'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    this.delete = function($scope,id){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'question/type/del',
            data:{id:id},
            method:"PUT"
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    this.update = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'question/type',
            data:$scope.data,
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    this.toTop = function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain + 'question/type/toTop',
            data:{id:$scope.questionType.id},
            method:'PUT'
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }
}]);